package org.travel_system.mapper;

import org.apache.ibatis.annotations.*;
import org.travel_system.pojo.Spot;

import java.util.List;

@Mapper
public interface SpotMapper
{
    @Select("select * from spot")
    List<Spot> getSpots();

    @Select("select * from spot where spot_name = #{name}")
    Spot getSpotByName(String name);

    @Insert("insert into spot(spot_name, phone_number, open_time, price) values (#{spotName}, #{phoneNumber}, #{openTime}, #{price})")
    int addSpot(Spot spot);

    @Delete("delete from spot where spot_name = #{name}")
    int deleteSpotByName(String name);

    @Update("update spot set phone_number = #{phoneNumber}, open_time = #{openTime}, price = #{price} where spot_name = #{spotName}")
    int updateSpot(Spot spot);
}
